#!/usr/bin/python3
"""
No-op mount service

Does not mount anything, but only creates an empty directory.
Useful for testing.

Host commands used: mount
"""

import os
import sys
from typing import Dict

from osbuild import mounts


SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
  "name": { "type": "string" },
  "type": { "type": "string" },
  "source": {
    "type": "string"
  },
  "target": {
    "type": "string"
  },
  "options": {
    "type": "object",
    "additionalProperties": true
  }
}
"""


class NoOpMount(mounts.MountService):

    def mount(self, args: Dict):
        root = args["root"]
        target = args["target"]

        mountpoint = os.path.join(root, target.lstrip("/"))

        os.makedirs(mountpoint, exist_ok=True)
        self.mountpoint = mountpoint

        return mountpoint

    def umount(self):
        self.mountpoint = None

    def sync(self):
        pass


def main():
    service = NoOpMount.from_args(sys.argv[1:])
    service.main()


if __name__ == '__main__':
    main()
